/**********************************************************
 * StatisticsAction.java
 * Created by ankur
 * Last modified Date: Aug 5, 2008 11:37:55 AM by ankur
 * Version : 0.1
 * Copyright (c) 2008 - 2008 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.List;

import org.apache.log4j.Logger;

import com.printeverywhere.delegator.CategoryManagerServiceDelegator;
import com.printeverywhere.delegator.CommonFunctionDelegator;
import com.printeverywhere.delegator.FeedbackServiceDelegator;
import com.printeverywhere.delegator.LocationCategoriesServiceDelegator;
import com.printeverywhere.delegator.UserServiceDelegator;
import com.printeverywhere.dto.AuctionCount;
import com.printeverywhere.dto.BidCount;
import com.printeverywhere.dto.CategoriesCount;
import com.printeverywhere.dto.FeedBackCount;
import com.printeverywhere.util.SearchCriteria;

/**
 * The Class StatisticsAction.
 */
public class StatisticsAction extends AdminEngineManagement {

	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(StatisticsAction.class);

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}

		SearchCriteria searchCriteria = new SearchCriteria();
		totalRegisteredUser= UserServiceDelegator.getUserCount(searchCriteria);
		searchCriteria.setAttribute("active".intern(), true);
		totalActiveUser = UserServiceDelegator.getUserCount(searchCriteria);
		feedBackCount=FeedbackServiceDelegator.getCount();
		totalSuspendedUser=totalRegisteredUser-totalActiveUser;
		locationCategories = LocationCategoriesServiceDelegator.getCount();
		List l= CommonFunctionDelegator.getAllfromtable("com.printeverywhere.dto.AuctionCount");
		if(l!=null && l.size()>0)
		auctionCount =(AuctionCount)l.get(0);
		else{
			auctionCount=new AuctionCount();
		}
		categoriesCount=CategoryManagerServiceDelegator.findAll();
		l = CommonFunctionDelegator.getAllfromtable("com.printeverywhere.dto.BidCount");
		if(l!=null && l.size()>0)
		bidCount=(BidCount)l.get(0);
		else{
			bidCount=new BidCount();
		}

		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); 
		}

		return SUCCESS;
	}

	/** The total registered user. */
	private int totalRegisteredUser;

	private AuctionCount auctionCount;

	/** The feed back count. */
	private FeedBackCount feedBackCount;

	private BidCount bidCount;
	private CategoriesCount categoriesCount;
	
	/** The total active user. */
	private int totalActiveUser;

	/** The total suspended user. */
	private int totalSuspendedUser;

	/** The total Location Categories. */
	private int locationCategories;

	/**
	 * Gets the location categories.
	 *
	 * @return the locationCategories
	 */
	public int getLocationCategories() {
		return locationCategories;
	}

	/**
	 * Sets the location categories.
	 *
	 * @param locationCategories the locationCategories to set
	 */
	public void setLocationCategories(int locationCategories) {
		this.locationCategories = locationCategories;
	}

	/**
	 * Gets the total registered user.
	 *
	 * @return the total registered user
	 */
	public int getTotalRegisteredUser() {
		return totalRegisteredUser;
	}

	/**
	 * Sets the total registered user.
	 *
	 * @param totalRegisteredUser the new total registered user
	 */
	public void setTotalRegisteredUser(int totalRegisteredUser) {
		this.totalRegisteredUser = totalRegisteredUser;
	}

	/**
	 * Gets the total active user.
	 *
	 * @return the total active user
	 */
	public int getTotalActiveUser() {
		return totalActiveUser;
	}

	/**
	 * Sets the total active user.
	 *
	 * @param totalActiveUser the new total active user
	 */
	public void setTotalActiveUser(int totalActiveUser) {
		this.totalActiveUser = totalActiveUser;
	}

	/**
	 * Gets the total suspended user.
	 *
	 * @return the total suspended user
	 */
	public int getTotalSuspendedUser() {
		return totalSuspendedUser;
	}

	/**
	 * Sets the total suspended user.
	 *
	 * @param totalSuspendedUser the new total suspended user
	 */
	public void setTotalSuspendedUser(int totalSuspendedUser) {
		this.totalSuspendedUser = totalSuspendedUser;
	}

	/**
	 * Gets the feed back count.
	 *
	 * @return the feed back count
	 */
	public FeedBackCount getFeedBackCount() {
		return feedBackCount;
	}

	/**
	 * Sets the feed back count.
	 *
	 * @param feedBackCount the new feed back count
	 */
	public void setFeedBackCount(FeedBackCount feedBackCount) {
		this.feedBackCount = feedBackCount;
	}

	/**
	 * @return the categoriesCount
	 */
	public CategoriesCount getCategoriesCount() {
		return categoriesCount;
	}

	/**
	 * @param categoriesCount the categoriesCount to set
	 */
	public void setCategoriesCount(CategoriesCount categoriesCount) {
		this.categoriesCount = categoriesCount;
	}

	/**
	 * @return the auctionCount
	 */
	public AuctionCount getAuctionCount() {
		return auctionCount;
	}

	/**
	 * @param auctionCount the auctionCount to set
	 */
	public void setAuctionCount(AuctionCount auctionCount) {
		this.auctionCount = auctionCount;
	}

	/**
	 * @return the bidCount
	 */
	public BidCount getBidCount() {
		return bidCount;
	}

	/**
	 * @param bidCount the bidCount to set
	 */
	public void setBidCount(BidCount bidCount) {
		this.bidCount = bidCount;
	}

}
